# project/urls.py
from django.contrib import admin
from django.urls import path, include
from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
    TokenVerifyView
)
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView, SpectacularRedocView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),

    # API 路由 - 按应用分组
    path('api/', include([
        # 认证
        path('auth/', include([
            path('login/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
            path('refresh/', TokenRefreshView.as_view(), name='token_refresh'),
            path('verify/', TokenVerifyView.as_view(), name='token_verify'),
        ])),

        # 核心功能
        path('', include('apps.users.urls')),
        path('subjects/', include('apps.subjects.urls')),
        path('tags/', include('apps.tags.urls')),
        path('questions/', include('apps.questions.urls')),
        path('exam-papers/', include('apps.exam_papers.urls')),
        path('imports/', include('apps.imports.urls')),
        path('api/menus/', include('apps.menus.urls')),
        path('api/roles/', include('apps.roles.urls')),
        path('', include('apps.audit.urls')),

        # 通用接口
        path('core/', include('apps.core.urls')),
    ])),

    # OpenAPI 文档
    path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
    path('api/docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
    path('api/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
]